1. Field of the Invention
The present invention relates to a wear leveling method. More particularly, the present invention relates to a wear leveling method for a non-volatile memory and a controller using the same.
2. Description of Related Art
With a quick developing of digital camera, cell phone camera and MP3, demand of storage media by customers is increased greatly. Since a flash memory has the advantages of non-volatile, energy saving, small size and none mechanical structure etc., it is suitable for portable applications, and especially for portable battery-powered products. Besides a demand of built-in memories of the portable products, demand of the flash memories used for external products such as small memory cards and flash drives is increased greatly in the market, since a user may simultaneously own a plurality of the memory cards and the flash drives. Therefore, the flash drive industry becomes a hot industry within the electronics industry recently.
Though the flash drive has the advantages of programmable, erasable, data saving after power-off, erase times of memory blocks within the flash memory are limited. For example, the memory blocks may be worn after ten thousand times of erase. When wearing of the memory blocks causes a loss of storage volume or an obvious decreasing of performance, the adverse effects such as loss of the stored data or unable of storing data may be occurred.
Wearing of the flash memory blocks is determined by program and erase times of each block. Namely, if a block is only programmed (or written) for once, and none programming is performed afterwards, wearing of the block is relatively low. Conversely, if the block is repeatedly programmed and erased, wearing of the block is relatively high. For example, if a host for accessing the memory blocks repeatedly performs programming by using a same logical block address, the block with the same physical address within the flash memory may be programmed and erased repeatedly.
When some blocks are worn, and meanwhile some other blocks are relatively not, the worn blocks may generally decrease the performance of the flash drive. Besides a performance decreasing of the worn blocks itself, if the unworn blocks are not sufficient for storing data, the whole performance of the flash drive decreases accordingly. Namely, when a number of the worn blocks of the flash drive is greater than a threshold value, even if there are still other unworn blocks, the flash drive is judged to be useless. When the unworn blocks are regarded useless, it is actually a waste of resources.
To prolong a lifespan of the flash drive, utilization of the blocks in the flash drive should be leveled. Generally, the blocks of the flash drive are grouped into a data area and a spare area. According to a conventional wear leveling method, when the flash drive is operated for a period of time, the blocks within the data area and the blocks within the spare area are logically exchanged sequentially, hopefully the blocks with lesser erase times may be exchanged to the data area for being programmed (or written). However, such method for logically exchanging the blocks within the data area sequentially to the blocks within the spare area cannot ensure the exchanged blocks are those with lesser erase times, and if the exchanged blocks are those with greater erase times, wearing of the blocks may be accelerated, and therefore an effect of the conventional wear leveling method is limited.
Accordingly, a novel wear leveling method is required to effectively prolong the lifespan of the flash drive.